import {
  bannerModel, // 首页banner模块
  recordModel, // 购买记录模块
  packageModel, // 套餐模块
  groupModel, // 团购模块
  shopModel, // 店铺地址模块
  notesModel, // 购买须知模块
  submitModel, // 生成海报、抢购
  // shareModel, // 分享
} from './model-config'

const setAppModelChild = (modelId, modelClass) => {
  let fn = (param, props) => {
    let base = JSON.parse(JSON.stringify(props.base))
    base['config']['model'] = modelId
    base['config']['class'] = `${modelClass} ${props.base['config']['class']}`
    param = {...param, ...base || {}}
    return [param]
  }
  let bannerUI = bannerModel[modelId] ? fn(bannerModel[modelId], bannerModel) : []
  let packageUI = packageModel[modelId] ? fn(packageModel[modelId], packageModel) : []
  let groupUI = groupModel[modelId] ? fn(groupModel[modelId], groupModel) : []
  let shopUI = shopModel[modelId] ? fn(shopModel[modelId], shopModel) : []
  let recordUI = recordModel[modelId] ? fn(recordModel[modelId], recordModel) : []
  let notesUI = notesModel[modelId] ? fn(notesModel[modelId], notesModel) : []
  let submitUI = submitModel[modelId] ? fn(submitModel[modelId], submitModel) : []
  // let shareUI = shareModel[modelId] ? fn(shareModel[modelId], shareModel) : []
  // if()
  return [...bannerUI, ...groupUI, ...packageUI, ...recordUI, ...shopUI, ...notesUI, ...submitUI]
}


export const fontSizeList = [
  {label: '8px', val: 8},
  {label: '12px', val: 12},
  {label: '13px', val: 13},
  {label: '14px', val: 14},
  {label: '16px', val: 16},
  {label: '18px', val: 18},
  {label: '20px', val: 20},
  {label: '21px', val: 21}
]
export const fontFamilyList = [
  {label: '微软雅黑', val: 'inherit'}
]

export const appModelList = [
  {isHidden: true, label: '模板1', modelName: 'appModel1', backgroundImg: '', background: '#fff', pageTitle: '模板', pageDesc: '这是模板的默认页面描述', modelClass: 'app-model-1', child: []},
  {isHidden: true, label: '模板2', modelName: 'appModel2', backgroundImg: '', background: '#fff', pageTitle: '模板', pageDesc: '这是模板的默认页面描述', modelClass: 'app-model-2', child: []},
  {isHidden: false, label: '模板3', modelName: 'appModel3', 
  backgroundImg: 'http://aicheduoduo.oss-cn-beijing.aliyuncs.com/Digitaltrade/44ea44f3ed5f46959dc073af4f790ec8.png', background: '#D82924', 
  pageTitle: '模板', pageDesc: '这是模板的默认页面描述', modelClass: 'app-model-3', child: []},
  {isHidden: true, label: '模板4', modelName: 'appModel4', backgroundImg: '', background: '#fff', pageTitle: '模板', pageDesc: '这是模板的默认页面描述', modelClass: 'app-model-4', child: []},
  {isDefault: true, isHidden: false, label: '模板5', modelName: 'appModel5', 
  backgroundImg: 'http://aicheduoduo.oss-cn-beijing.aliyuncs.com/Digitaltrade/aa04aad75a8d4848af671a9c987dd95a.png', background: '#fff', 
  pageTitle: '模板', pageDesc: '这是模板的默认页面描述', modelClass: 'app-model-5', child: []},
]

/**
 * Created by puffing on 2020-12-04.
 */
export const modelList = [  
  {
    typeId: 'DIMAGE',
    config: {
      label: '内嵌图片',
      icon: 'el-icon-goods',
      tag: 'd-image',
      isDragResize: true,
    },
    configH5: {
      imageUrl: '',
      w: '',
      h: '',
      top: '',
      left: ''
    },
    dragConfig: {
      w: 200,
      h: 200,
      left: 0,
      top: 0
    },
  },
  {
    typeId: 'DPIC',
    config: {
      label: '模板图片',
      icon: 'el-icon-goods',
      tag: 'd-pic',
      isDragResize: false,
    },
    configH5: {
      imageUrl: '',
      w: '',
      h: '',
      top: '',
      left: ''
    },
  },
  {
    typeId: 'DINPUT',
    config: {
      label: '文本',
      icon: 'el-icon-goods',
      tag: 'd-input',
      isDragResize: true,
    },
    configH5: {
      text: '单行文本',
      fontFamily: 'inherit',
      fontSize: 14,
      color: '#333',
      w: '',
      h: '',
      top: '',
      left: ''
    },
    dragConfig: {
      w: 100,
      h: 36,
      left: 0,
      top: 0
    }
  },
  {
    typeId: 'DTEXTAREA',
    config: {
      label: '多行文本',
      icon: 'el-icon-goods',
      tag: 'd-textarea',
      isDragResize: true,
    },
    configH5: {
      text: '多行文本',
      fontFamily: 'inherit',
      fontSize: 14,
      color: '#333',
      w: '',
      h: '',
      top: '',
      left: ''
    },
    dragConfig: {
      w: 100,
      h: 36,
      left: 0,
      top: 0
    }
  },
  // {
  //   typeId: 'DINUT',
  //   config: {
  //     label: '分割线',
  //     icon: 'el-icon-goods',
  //     tag: 'd-input',
  //     isDragResize: true,
  //   },
  //   dragConfig: {
  //     w: 200,
  //     h: 200,
  //     left: 0,
  //     top: 0
  //   }
  // },
  {
    typeId: 'DSHOP',
    config: {
      model: 'appModel3',
      label: '店铺地址',
      icon: 'el-icon-goods',
      tag: 'd-shop',
      class: 'app-model-3 shop-model'
    },
    configH5: {
      backgroundColor: '#fff',
      borderRadius: 20
    }
  },
  {
    typeId: 'DPACKAGE',
    config: {
      model: 'appModel3',
      label: '套餐',
      icon: 'el-icon-goods',
      tag: 'd-package',
      class: 'app-model-3 package-model',
      ignore: ['4'],
    },
    configH5: {
      backgroundColor: '#D82924'
    }
  },
  {
    typeId: 'DGROUPPACKAGE',
    config: {
      model: 'appModel3',
      label: '套餐',
      icon: 'el-icon-goods',
      tag: 'd-group-package',
      class: 'app-model-3 group-package-model',
      ignore: ['1', '2', '3', '5', '6'],
    },
    configH5: {
      backgroundColor: '#D82924'
    }
  },
  // {
  //   typeId: 'DSHARE',
  //   config: {
  //     model: 'appModel3',
  //     label: '分享',
  //     icon: 'el-icon-goods',
  //     tag: 'd-share',
  //     class: 'app-model-3 share-model',
  //     isDragResize: true,
  //   },
  //   configH5: {
  //     imageUrl: '',
  //     w: '80',
  //     h: '80',
  //     top: '345',
  //     left: '600'
  //   },
  //   dragConfig: {
  //     w: 80,
  //     h: 80,
  //     left: 345,
  //     top: 600
  //   }
  // },
  {
    typeId: 'DRECRD',
    config: {
      model: 'appModel3',
      label: '购买记录',
      icon: 'el-icon-goods',
      tag: 'd-record',
      class: 'app-model-3 record-model'
    },
    configH5: {
      backgroundColor: '#2D2C2A',
      borderRadius: 20
    }
  }
]

appModelList.forEach(model => {
  model.child = [...model.child, ...(setAppModelChild(model.modelName, model.modelClass) || [])]
})
